import datetime
import os

from . import settings
from .hrunFromExcel import ExcelCall


def call_excel(excelfile, outfile="", loglevel='INFO', isExtendReport=False, reportURL='', sheetType='Sheet1'):
    # if outfile == "":
    #     outfile = "%s-%s.json" % (".".join((os.path.basename(excelfile).split('.')[0:-1])),
    #                               datetime.datetime.now().strftime('%Y%m%d%H%M%S'))

    xlsCaller = ExcelCall(workdir=os.path.dirname(os.path.abspath(os.path.dirname(excelfile))))
    xlsCaller.CallHrunExcel(os.path.abspath(excelfile), sheetType, outfile, log_level=loglevel, isExtendReport=isExtendReport,
                            reportURL=reportURL)


def callexcel():
    excelfile = "demo_httprunner.xls"
    excelfile = "F:\\zsah_work\\shoubahrun\\testcases\\shoubalogin.xls"
    excelfile = "workdir\\excel\\yuncuang.xls"
    call_excel(excelfile)


if __name__ == "__main__":
    callexcel()
